42 #include "event_groups.h" 45 #include "fsl_debug_console.h" 48 #include "clock_config.h" 51 #include "Driver_I2C_SDK2.h" 52 #include "fxas21002.h" 68 static void read_task(
void *pvParameters);
74 ARM_DRIVER_I2C*
I2Cdrv = &I2C_S_DRIVER_BLOCKING;
77 BOARD_InitDebugConsole();
79 I2Cdrv->Initialize(NULL);
81 I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
92 xTaskCreate(
read_task,
"READ", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL);
93 xTaskCreate(
fusion_task,
"FUSION", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
96 vTaskStartScheduler();
104 portTickType lastWakeTime;
105 const portTickType frequency = 1;
106 lastWakeTime = xTaskGetTickCount();
110 vTaskDelayUntil(&lastWakeTime, frequency);
void initSensorFusionGlobals(SensorFusionGlobals *sfg, StatusSubsystem *pStatusSubsystem, ControlSubsystem *pControlSubsystem)
utility function to insert default values in the top level structure
int32_t loopcounter
counter incrementing each iteration of sensor fusion (typically 25Hz)
static void read_task(void *pvParameters)
conditionSensorReadings_t * conditionSensorReadings
preprocessing step for sensor fusion
int8_t FXOS8700_Read(PhysicalSensor *sensor, SensorFusionGlobals *sfg)
void initializeStatusSubsystem(StatusSubsystem *pStatus)
initializeStatusSubsystem() should be called once at startup to initialize the data structure and to ...
The top level fusion structure.
streamData_t * stream
function to create packets for serial stream
installSensor_t * installSensor
function for installing a new sensor into t
StatusSubsystem() provides an object-like interface for communicating status to the user...
static void fusion_task(void *pvParameters)
readSensors_t * readSensors
read all physical sensors
struct ControlSubsystem * pControlSubsystem
initializeFusionEngine_t * initializeFusionEngine
set sensor fusion structures to initial values
StatusSubsystem statusSubsystem
provides visual (usually LED) status indicator
updateStatus_t * updateStatus
status=next status
int8_t FXOS8700_Init(PhysicalSensor *sensor, SensorFusionGlobals *sfg)
int8_t FXAS21002_Read(PhysicalSensor *sensor, SensorFusionGlobals *sfg)
The sensor_fusion.h file implements the top level programming interface.
SensorFusionGlobals sfg
This is the primary sensor fusion data structure.
Provides function prototypes for driver level interfaces.
he ControlSubsystem encapsulates command and data streaming functions.
uint8_t sUARTOutputBuffer[256]
main output buffer defined in control.c
int main(void)
This is a FreeRTOS (dual task) implementation of the NXP sensor fusion demo build.
int8_t initializeControlPort(ControlSubsystem *pComm)
Initialize the control subsystem and all related hardware.
runFusion_t * runFusion
run the fusion routines
ARM_DRIVER_I2C * I2Cdrv
KSDK handle for the I2C port defined in Driver_I2C_KSDK2.c.
Non-recoverable FAULT = something went very wrong.
Application-specific status subsystem.
An instance of PhysicalSensor structure type should be allocated for each physical sensors (combo dev...
ControlSubsystem controlSubsystem
used for serial communications
PhysicalSensor sensors[2]
This implementation uses two physical sensors.
setStatus_t * queueStatus
queue status change for next regular interval
Defines control sub-system.
EventGroupHandle_t event_group
setStatus_t * setStatus
change status indicator immediately
applyPerturbation_t * applyPerturbation
apply step function for testing purposes
int8_t FXAS21002_Init(PhysicalSensor *sensor, SensorFusionGlobals *sfg)